package com.example.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.feign.clients.UserClient;
import com.example.feign.pojo.UserResponse;
import com.example.order.mapper.OrderMapper;
import com.example.order.pojo.Order;
import com.example.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
	@Autowired
	private RestTemplate restTemplate;

	@Autowired
	private UserClient userClient;
	@Override
	public Order queryById(String id) {
		Order order= baseMapper.selectById(id);
		// String url="http://user-service/users/query/"+order.getUserId();
		// UserResponse response = restTemplate.getForObject(url, UserResponse.class);
		// order.setUser(response);
		UserResponse response =userClient.findById(id);
		order.setUser(response);
		return order;
	}
}
